<script type="text/javascript">
	$(document).ready(function(){
		$.validator.messages.required = "";
		$.validator.messages.date = "";
		$("#FormSuaBaiViet").validate();
	});
</script>
<?php
	$baiviet = new noidungtinbs();
	$baiviet->MaBaiViet = $_GET['id'];
	$dsbaiviet = $baiviet->GetAllList();
?>
<h3>Sửa bài viết</h3>
<form id = "FormSuaBaiViet" action="index.php?do=baiviet_sua_xuly" method="post" enctype="multipart/form-data">
	<table class="FormSuaBaiViet">
		
		<input type="hidden" name="MaBaiViet" value="<?php echo $dsbaiviet[0]['MaBaiViet']; ?>" />
		
		<tr>
			<td>
				<span class="MyFormLabel">Tiêu đề:</span>
				<input type="text" name="TieuDe" value="<?php echo $dsbaiviet[0]['TieuDe']; ?>" class = "required"/>
			</td>
		</tr>
		<tr>
			<td>
				<span class="MyFormLabel">Chủ đề:</span>
				<select name="ChuDe" class = "required">
					<option value="">-- Chọn --</option>
					<?php
						$chude = new chudebs();
						$danhsach = $chude->GetList();
						
						for($i = 0; $i < ($danhsach == false ? 0 : count($danhsach)); $i++)
						{
							if($danhsach[$i]['MaChuDe'] == $dsbaiviet[0]['MaChuDe'])
								echo "<option value='" . $danhsach[$i]['MaChuDe'] . "' selected = 'selected'>" . $danhsach[$i]['TenChuDe'] . "</option>";
							else
								echo "<option value='" . $danhsach[$i]['MaChuDe'] . "'>" . $danhsach[$i]['TenChuDe'] . "</option>";
						}
					?>
				</select>
			</td>
		</tr>
		<tr>
			<td>
				<span class="MyFormLabel">Tóm tắt:</span>
				<textarea name="TomTat" class = "required"><?php echo $dsbaiviet[0]['TomTat']; ?></textarea>
			</td>
		</tr>
		<tr>
			<td>
				<span class="MyFormLabel">Hình ảnh:</span>
				<span><img src = "<?php echo $dsbaiviet[0]['HinhAnh'] ?>" width = "300"/></span><br/>
				<input type="file" name="HinhAnh" size="50"/>
			</td>
		</tr>
		<tr>
			<td>
				<span class="MyFormLabel">Tên ảnh:</span>
				<input type="text" name="TenAnh" size="50"value = "<?php echo $dsbaiviet[0]['TenAnh'] ?>"/>
			</td>
		</tr>
		<tr>
			<td>
				<span class="MyFormLabel">Nội dung bài viết:</span>
				<textarea name="NoiDung" id="NoiDung" class = "required"><?php echo $dsbaiviet[0]['NoiDung']; ?></textarea>
				<script type="text/javascript">
					var editor = CKEDITOR.replace('NoiDung');
				</script>
			</td>
		</tr>
	</table>
	
	<input type="submit" value="Cập nhật" />
</form>